package cn.xbtop.blog.service.impl;

import cn.xbtop.blog.mapper.LinkMapper;
import cn.xbtop.blog.pojo.Link;
import cn.xbtop.blog.service.LinkService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author  Mxb
 * @date  2020/2/19 15:56
 * @version 1.0
 */
@Service
public class LinkServiceImpl implements LinkService{

    @Resource
    private LinkMapper linkMapper;

    /**
     * 通过id删除
     * @param linkId
     * @return
     */
    @Override
    public int deleteByPrimaryKey(Integer linkId) {
        return linkMapper.deleteByPrimaryKey(linkId);
    }

    /**
     * 添加链接
     * @param link
     * @return
     */
    @Override
    public int insert(Link link) {
        link.setCreatedTime(new Date());
        link.setUpdateTime(new Date());
        return linkMapper.insert(link);
    }

    @Override
    public Link selectByPrimaryKey(Integer linkId) {
        return linkMapper.selectByPrimaryKey(linkId);
    }

    /**
     * 通过id更新
     * @param link
     * @return
     */
    @Override
    public int updateByPrimaryKey(Link link) {
        return linkMapper.updateByPrimaryKey(link);
    }

    /**
     * 查询所有
     * @return
     */
    @Override
    public List<Link> findAll() {
        return linkMapper.findAll();
    }
}
